<?php

class Ext_Queue_ExecMessage extends Ext_Message
{
    const VERSION = '1.0';

    public function __construct( $msg = null )
    {
        $this->getData( $msg );
    }

    public function getData( $msg = null )
    {
        $data = parent::getData( $msg );
        if ( $data != null ) {//TODO: Validate message.
        } else { // Initialize Data.
            $data = array( 
                            'version' => self::VERSION 
            );
            parent::setData( $data );
        }
        return $data;
    }

    public function setFunction( $function )
    {
        $data = $this->getData();
        $data[ 'function' ] = $function;
        parent::setData( $data );
    }

    public function setArguments( $args )
    {
        $data = $this->getData();
        $data[ 'args' ] = $args;
        parent::setData( $data );
    }

    public function getFunction()
    {
        $data = $this->getData();
        if ( ! isset( $data[ 'function' ] ) ) {
            throw new Exception( 'function not found' );
        }
        return $data[ 'function' ];
    }

    public function getArguments()
    {
        $data = $this->getData();
        if ( ! isset( $data[ 'args' ] ) ) {
            throw new Exception( 'args not found' );
        }
        return $data[ 'args' ];
    }
}


